import { BaseCommand } from "./BaseCommand";
import { API_EVENT, COMMAND_STATUS } from "@/FrontProcessing/interface";
/**
 * Cmd_Mid_Surface
 * @description 抽中面
 */
export class Cmd_Edge_Partition extends BaseCommand {
  event = API_EVENT.Edge_Partition;
  execute(): Promise<any> {
    this.system.history.push(this);
    return new Promise((resolve, reject) => {
      this.status = COMMAND_STATUS.RUNNING;
      this.system.edge_partition(this.params).then((res) => {
        this.status = COMMAND_STATUS.FINISHED;
        resolve(res);
      }).catch(err => reject(err));
    });
  }

  undo(): boolean {
    return false;
  }
}
export class Cmd_Edge_Bias extends BaseCommand {
  event = API_EVENT.Edge_Partition;
  execute(): Promise<any> {
    this.system.history.push(this);
    return new Promise((resolve, reject) => {
      this.status = COMMAND_STATUS.RUNNING;
      this.system.edge_mesh_bias(this.params).then((res) => {
        this.status = COMMAND_STATUS.FINISHED;
        resolve(res);
      }).catch(err => reject(err));
    });
  }

  undo(): boolean {
    return false;
  }
}
export class Cmd_Edge_Ratio extends BaseCommand {
  event = API_EVENT.Edge_Get_Ratio;
  execute(): Promise<any> {
    this.system.history.push(this);
    return new Promise((resolve, reject) => {
      this.status = COMMAND_STATUS.RUNNING;
      this.system.edge_get_ratio(this.params).then((res) => {
        this.status = COMMAND_STATUS.FINISHED;
        resolve(res);
      }).catch(err => reject(err));
    });
  }

  undo(): boolean {
    return false;
  }
}
export class Cmd_Edge_Leave extends BaseCommand {
  event = API_EVENT.Edge_Leave;
  execute(): Promise<any> {
    this.system.history.push(this);
    return new Promise((resolve, reject) => {
      this.status = COMMAND_STATUS.RUNNING;
      this.system.edge_mesh_leave(this.params).then((res) => {
        this.status = COMMAND_STATUS.FINISHED;
        resolve(res);
      }).catch(err => reject(err));
    });
  }

  undo(): boolean {
    return false;
  }
}
